import { ICursorPagination } from './pagination'
import { IQueryParams } from './queryParams'
import { IOption } from './common'

export class PostRiskScheme {
  insCode: string | Institution
  schemeCode: string
  schemeName: string
  schemeDesc: string
  ruleList?: RiskRules[]
  createdAt: string
  updatedAt: string
  status?: string
  currency?: string
  mcccList?: string[]
  mcccInfoList?: MccInfo[]
  storeInfoList?: StoreInfo[]
  intStoreCodeList?: string[]
  ruleLists?: RiskRules[]
  constructor(code?: string, name?: string) {
    this.schemeCode = code
    this.schemeName = name
  }
}

export interface MccInfo {
  mccCode: string
  mccEnName: string
}

export interface StoreInfo {
  code: string
  level: string
  name: string
  nameEN: string
  num: string
}

export interface Institution {
  code: string
  name: string
  num: string
  level: string
  nameEN: string
}

export interface IRiskControlSchemeQuery {
  limit: number
  keyword?: string
  size?: number
  page: number
  before?: string
  after?: string
  category?: string
}

export class PostRisk {
  version: number
  createdAt: string
  updatedAt: string
  common: PostRiskScheme
  constructor() {
    this.common = new PostRiskScheme()
  }
}

export interface IRiskControlSchemePagination extends ICursorPagination {
  data: PostRiskScheme[]
}

export class PostRiskFull {
  postRisk: PostRiskScheme
}

export interface IRiskControlQueryParams extends IQueryParams {
  schemeCode?: string
  schemeName?: string
  submittedAtFrom?: string
  submittedAtTo?: string
}

export class RiskRules {
  createdAt?: string
  updatedAt?: string
  ruleID?: string
  ruleType?: string
  ruleName?: string
  threshold?: any
  schemeCode?: string
  thresholdDesc?: string
  score?: any
  status?: number
  showTransFlag?: string
  thresholdType?: string

}

export interface IRiskControlBiz {
  biz: string
  bizId: string
  name: string
  nameEn: string
  RiskRules: RiskRules[]
}

export enum RiskRuleModeEnum {
  Trade = '00',
  Day = '01',
  Month = '30',
  Refund = 'refund',
}

export const RiskRuleModeMap = {
  '00': 'RISK_CTRL_RULE_MODE.SINGLE',
  '01': 'RISK_CTRL_RULE_MODE.SINGLE_DAY',
  30: 'RISK_CTRL_RULE_MODE.SINGLE_MONTH',
  refund: 'RISK_CTRL_RULE_MODE.REFUND',
}

export enum OperateType {
  copy = 1,
  edit = 2,
}
